﻿Public Class ClscnComprobanteC

    Inherits ClsSQL

    Dim Compro_id As Integer
    Dim periodo As Char
    Dim tipo As Integer
    Dim nrotipo As Integer
    Dim docto_id As Integer
    Dim nrodocto As Integer
    Dim moneda_id As Integer
    Dim Fecha As Date
    Dim importeNac As Double
    Dim importeExt As Double
    Dim tipocambio As Double
    Dim glosa As String
    Dim impresion As Integer
    Dim estado As Integer
    Dim usuario As String
    Dim fechareg As Date
    Dim usuariomodif As String
    Dim fechamodif As Date


#Region "Propiedades"
    Property Pcompro_id() As Integer
        Get
            Return Compro_id
        End Get
        Set(ByVal value As Integer)
            Compro_id = value
        End Set
    End Property
    Property Ptipo() As Integer
        Get
            Return tipo
        End Get
        Set(ByVal value As Integer)
            tipo = value
        End Set
    End Property
    Property Pnrotipo() As Integer
        Get
            Return nrotipo
        End Get
        Set(ByVal value As Integer)
            nrotipo = value
        End Set
    End Property
    Property Pdocto_id() As Integer
        Get
            Return docto_id
        End Get
        Set(ByVal value As Integer)
            docto_id = value
        End Set
    End Property
    Property Pnrodocto() As Integer
        Get
            Return nrodocto
        End Get
        Set(ByVal value As Integer)
            nrodocto = value
        End Set
    End Property
    Property Pglosa() As String
        Get
            Return glosa
        End Get
        Set(ByVal value As String)
            glosa = value
        End Set
    End Property
    Property Pestado() As String
        Get
            Return estado
        End Get
        Set(ByVal value As String)
            estado = value
        End Set
    End Property
#End Region

#Region "Procedmientos y Funciones"
    Public Function Insertar()
        Dim sql As String
        'sql = "INSERT INTO MOVIMIENTO VALUES ('" & Pfecha.Date.ToString("yyyyMMdd") & "','" & Pidalmacen & "','" & Pidlugar & "','" & Pidherramienta & "','" & Pcantidad & "', '" & Pidtipomovimiento & "', '" & Pidmovimiento & "','" & Pestado() & "')"
        Return (Me.Ejecutar(sql))
    End Function
    Public Function Modificar()
        Dim sql As String
        'sql = "UPDATE MOVIMIENTO SET IDTIPOMOVIMIENTO=5 WHERE IDTIPOMOVIMIENTO='" & Pidtipomovimiento() & "' AND IDMOVIMIENTO='" & Pidmovimiento() & "' "
        Return (Me.Ejecutar(sql))
    End Function
    Public Function Eliminar()
        Dim sql As String
        'sql = "UPDATE MOVIMIENTO SET IDTIPOMOVIMIENTO=6 WHERE IDTIPOMOVIMIENTO='" & Pidtipomovimiento() & "' AND IDMOVIMIENTO='" & Pidmovimiento() & "' "
        Return (Me.Ejecutar(Sql))
    End Function
    Sub ClsConectar(ByVal bd As String, Optional ByVal servidor As String = "")
        Select Case bd
            Case "administracion"
                Conectar(0)
            Case "corbol"
                Conectar(1)
            Case "importacion"
                Conectar(2)
            Case "corbol09"
                Conectar(3)
            Case "corbol2010"
                Conectar(4)
            Case "pruebas"
                Conectar(5)
            Case "corbol2011"
                Conectar(6)
        End Select
    End Sub
    Sub ClsDesConectar()
        Desconectar()
    End Sub
    Function ClsTraerDataTable(ByVal opcion As Int16, Optional ByVal filtro As String = "") As DataTable
        Select Case opcion
            Case 0
                'Return TraerTabla("VCnComproFl", "*", " TIPO='INGRESO' ORDER BY NroTipo DESC")
            Case 1
                Return Buscador("VCnComproFl", filtro)
            Case 2
                'Return Buscador("VpdOrdenC", "WHERE Orden_id=" & Porden_id() & " ")
            Case 3
                Return TraerTabla("VCnComproFl", "*", " TIPO='INGRESOS' ORDER BY NroTipo DESC")
            Case 4
                Return TraerTabla("VCnComproFl", "*", " TIPO='EGRESOS' ORDER BY NroTipo DESC")
            Case 5
                Return TraerTabla("VCnComproFl", "*", " TIPO='TRASPASOS' ORDER BY NroTipo DESC")
        End Select
    End Function
    Function ClsTraerDataSet(Optional ByVal opcion As Integer = 0) As DataSet
        'Select Case opcion
        '    Case 0
        '        Return TraerTablaDs("VALMACEN", "*")
        '        'Case 1
        '        '    Return BuscadorDs("VAUTOPORCLIENTE", "WHERE CLIENTE=" & Pidcliente() & " ")
        'End Select
    End Function

#End Region

End Class
